package ogb;

import static org.junit.Assert.assertEquals;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.events.TurnEndedEvent;
import robocode.control.testing.RobotTestBed;

/**
 * Tests that DeaconBlues is capable of outperforming the Walls sample robot.
 * Based on sample code from http://code.google.com/p/robocode-pmj-dacruzer/
 * 
 * @author Branden Ogata
 *
 */

public class TestDeaconBluesVersusWalls extends RobotTestBed {

  /**
   * Specifies that Walls and DeaconBlues are the ones involved in this match.
   * 
   * @return  The comma-delimited list of robots involved in the match.
   * 
   */
  
  @Override
  public String getRobotNames() {
    return "sample.Walls,ogb.DeaconBlues";
  }
  
  /**
   * Run eight test rounds.
   * 
   * @return  The number of rounds in the match.
   */
  @Override
  public int getNumRounds() {
    return 8;
  }
  
  /**
   * The actual test, which asserts that DeaconBlues has more points than Walls over the match.
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    // Return the results in order of score
    BattleResults[] deaconBluesResults = event.getSortedResults();

    // Check to make sure DeaconBlues got more points than Walls.
    assertEquals("Check points of DeaconBlues and Walls", "ogb.DeaconBlues*", 
                  deaconBluesResults[0].getTeamLeaderName());
  }
  
  /**
   * Called after each turn. 
   * Provided here to show that you could use this method as part of your testing.  
   * @param event The TurnEndedEvent.
   */
  @Override
  public void onTurnEnded(TurnEndedEvent event) {
    // You could add code here to check a condition after every turn or collect data. 
  }  
}
